package com.scau.database.service.admin;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scau.data.entity.UserDO;
import com.scau.database.common.service.ImportMapperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: x1aolone
 * @Date: 2020/5/9 18:34
 */
@Service
public class UserService{

    @Autowired
    public ImportMapperService importMapperService;

    /**
     * 插入用户
     * @param DO 用户信息
     * @return 插入数据库受影响行数
     */
    public Integer addUser(UserDO DO) {
        return importMapperService.userMapper.insert(DO);
    }

    /**
     * 列出所有用户
     * @return
     */
    public List<UserDO> echo() {
        LambdaQueryWrapper<UserDO> query = Wrappers.<UserDO>lambdaQuery()
//                .eq(UserDO::getName, "孔渔儿")
                .orderByDesc(UserDO::getId);
        List<UserDO> list = importMapperService.userMapper.selectList(query);
        list.forEach(x->System.err.println(x.toString()));
        return list;
    }

//    public List<UserDO> echoUser() {
//        LambdaQueryWrapper<UserDO> query = Wrappers.<UserDO>lambdaQuery()
//                .eq(UserDO::getId, "孔渔儿")
//                .orderByDesc(UserDO::getId);
//        List<UserDO> list = importMapperService.userMapper.selectList(query);
//        list.forEach(x->System.err.println(x.toString()));
//        return list;
//    }

}
